<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jq/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
	$(function() {
		$("#btn")
				.click(
						function() {
							if ($.trim($("#userName").val()) == "") {
								$("#userName").select();
								$("#userName").focus();
								$("#msg").html("用户名不能为空，请输入！");
								return;
							}
							;
							if ($.trim($("#pwd").val()) == "") {
								$("#pwd").select();
								$("#pwd").focus();
								$("#msg").html("密码不能为空，请输入");
								return;
							}
							;
							$
									.post(
											"${pageContext.request.contextPath }/user/CheckLogin.action",
											{
												"user.userName" : $("#userName")
														.val(),
												"user.pwd" : $("#pwd").val()
											},
											function(data) {
												if (data == "1") {
													location
															.href("${pageContext.request.contextPath }/main.jsp");
												} else {
													$("#msg").html(
															"用户名或密码错误,请重新输入");
												}

											});
						});
	});
</script>

</head>
<body>
	登录页面
	<br />
	<br />
	<form>
		<table width="247">
			<tr>
				<td width="60">用户名</td>
				<td width="171"><input type="text" name="userName"
					id="userName"></td>
			</tr>
			<tr>
				<td>密码</td>
				<td><input type="password" name="pwd" id="pwd"></td>
			</tr>
			<tr>
				<td colspan="2"><input type="button" id="btn" value="提交"></td>
			</tr>
		</table>
	</form>
	<div id="msg"></div>
	<br />
	<a href="${pageContext.request.contextPath }/main.jsp">返回主页面</a>

</body>
</html>